<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <script src="./libs/react.js"></script>
    <script src="./libs/react-dom.js"></script>
    <script src="./libs/babel.min.js"></script>
    <script type="text/babel">
      const { Component } = React;
      class App extends Component {
        constructor(props) {
          super(props);
          this.state = {
            count: 1,
            title: "",
          };
          this.keyUpHandle = this.keyUpHandle.bind(this);
        }
        clickHandle() {
          this.setState({
            count: this.state.count + this.props.step,
          });
        }
        keyUpHandle(e) {
          this.setState({
            title: e.target.value,
          });
        }
        render() {
          return (
            <div>
              <p>当前计数步长：{this.props.step}</p>
              <button onClick={() => this.clickHandle()}>
                当前计数值为：{this.state.count}
              </button>

              <button onClick={this.clickHandle.bind(this)}>
                计数值二:{this.state.count}
              </button>

              <h5>{this.state.title}</h5>
              <input type="text" onKeyUp={this.keyUpHandle} />
            </div>
          );
        }
      }
      ReactDOM.render(<App step={5} />, document.getElementById("app"));
    </script>
  </body>
</html>
